class Solution {
    public String multiply(String num1, String num2) {
        int n1 = 0;
        int n2 = 0;
        int res = 0;
        int[] a = new int[num1.length()];
        int[] b = new int[num2.length()];
        for (int i = 0 ; i < num1.length(); i++) {
            n1 = num1.charAt(i) - '0';
            a[i] = n1;
            System.out.println(a[i]);
        }
        for ( int i = 0; i < num2.length(); i++) {
            n2 = num2.charAt(i) - '0';
            b[i] = n2;
        }
        for(int i = num1.length()-1; i >= 0; i--)
            for (int j = num2.length()-1; j >= 0; j--) {
                System.out.println(a[i] * b[j]);
                System.out.println(res += a[i] * Math.pow(10, num1.length() - i - 1) * b[j] * Math.pow(10, num2.length() - j - 1));
            }
        System.out.println(res);
        return res + "";
    }

    public static void main(String[] args) {
        Solution s = new Solution();
        System.out.println(s.multiply("123456789", "987654321"));
    }
}